# 第一题
for i in range(1, 5):
    for j in range(1, 5):
        for k in range(1, 5):
            if i != j and i != k and j != k:
                print(i, j, k)
print("*" * 20)  # 分隔线
# 第二题
# year = int(input('year:'))
# month = int(input('month:'))
# day = int(input('day:'))
year = 2020
month = 3
day = 5

months = (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334)
if 0 < month <= 12:
    sum = months[month - 1]
else:
    print('data error')
sum += day
leap = 0
if (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0)):
    leap = 1
if (leap == 1) and (month > 2):
    sum += 1
print('it is the %dth day.' % sum)

print("*" * 20)  # 分隔线


# 第三题
# 方法一：
def fib(n):
    a, b = 1, 1
    for i in range(n - 1):
        a, b = b, a + b
    return a


# 输出了第10个斐波那契数列
print(fib(10))


# 方法二：
# 使用递归
def fib(n):
    if n == 1 or n == 2:
        return 1
    return fib(n - 1) + fib(n - 2)


# 输出了第10个斐波那契数列
print(fib(10))

print("*" * 20)  # 分隔线

# 第四题：
for n in range(100, 1000):
    i = n // 100
    j = n // 10 % 10
    k = n % 10
    if n == i * i * i + j * j * j + k * k * k:
        print(n)

print("*" * 20)  # 分隔线

# 第五题：
tour = []
height = []

hei = 100.0  # 起始高度
tim = 10  # 次数

for i in range(1, tim + 1):
    # 从第二次开始，落地时的距离应该是反弹高度乘以2（弹到最高点再落下）
    if i == 1:
        tour.append(hei)
    else:
        tour.append(2 * hei)
    hei /= 2
    height.append(hei)


def sum(list1):
    sum = 0
    for i in list1:
        sum += i
    return sum


print('总高度：tour = {0}'.format(sum(tour)))
print('第10次反弹高度：height = {0}'.format(height[-1]))

print("*" * 20)  # 分隔线

# 第六题：
x1 = 0
x2 = 1
for day in range(9, 0, -1):
    x1 = (x2 + 1) * 2
    x2 = x1
print(x1)

print("*" * 20)  # 分隔线

# 第七题：
for i in range(4):
    for j in range(2 - i + 1):
        print(' ', end='')
    for k in range(2 * i + 1):
        print('*', end='')
    print('')

for i in range(3):
    for j in range(i + 1):
        print(' ', end='')
    for k in range(4 - 2 * i + 1):
        print('*', end='')
    print('')

print("*" * 20)  # 分隔线

# 第八题：
a = 2.0
b = 1.0
s = 0
for n in range(1, 21):
    s += a / b
    t = a
    a = a + b
    b = t
print(s)

print("*" * 20)  # 分隔线


# 第九题：
def age(n):
    if n == 1:
        c = 10
    else:
        c = age(n - 1) + 2
    return c


print(age(5))

print("*" * 20)  # 分隔线

# 第十题：
# a = int(input("请输入一个数字:\n"))
a = 12321
x = str(a)
flag = True

for i in range(len(x) // 2):
    if x[i] != x[-i - 1]:
        flag = False
        break
if flag:
    print("%d 是一个回文数!" % a)
else:
    print("%d 不是一个回文数!" % a)

print("*" * 20)  # 分隔线

# 第十一题：
# letter = input("please input:")
# # while letter  != 'Y':
# if letter == 'S':
#     print('please input second letter:')
#     letter = input("please input:")
#     if letter == 'a':
#         print('Saturday')
#     elif letter == 'u':
#         print('Sunday')
#     else:
#         print('data error')
#
# elif letter == 'F':
#     print('Friday')
#
# elif letter == 'M':
#     print('Monday')
#
# elif letter == 'T':
#     print('please input second letter')
#     letter = input("please input:")
#
#     if letter == 'u':
#         print('Tuesday')
#     elif letter == 'h':
#         print('Thursday')
#     else:
#         print('data error')
#
# elif letter == 'W':
#     print('Wednesday')
# else:
#     print('data error')

print("*" * 20)  # 分隔线

# 第十二题：
# 指定范围
lower = 1
upper = 100

for num in range(lower, upper + 1):
    # 素数大于 1
    if num > 1:
        for i in range(2, num):
            if (num % i) == 0:
                break
        else:
            print(num)
print("*" * 20)

# 第十三题：
a = 1234
aa = []
aa.append(a % 10)
aa.append(a % 100 // 10)
aa.append(a % 1000 // 100)
aa.append(a // 1000)
for i in range(4):
    aa[i] += 5
    aa[i] %= 10
for i in range(2):
    aa[i], aa[3 - i] = aa[3 - i], aa[i]
for i in range(3, -1, -1):
    print(aa[i], end='')
print()
print("*" * 20)

# 第十四题：
i = 0
j = 1
x = 0
while i < 5:
    x = 4 * j
    for i in range(0, 5):
        if x % 4 != 0:
            break
        else:
            i += 1
        x = (x / 4) * 5 + 1
    j += 1
print(x)
print("*" * 20)

# 第十五题：
n = 34  # 总人数
num = []
for i in range(n):
    num.append(i + 1)

i = 0
k = 0
m = 0

while m < n - 1:
    if num[i] != 0:
        k += 1
    if k == 3:
        num[i] = 0
        k = 0
        m += 1
    i += 1
    if i == n:
        i = 0

i = 0
while num[i] == 0:
    i += 1
print(num[i])
